<template>
  <!--开票信息-->
  <el-dialog
    :close-on-click-modal="false"
    title="开票信息"
    :beforeClose="handleClose"
    :visible.sync="dialogVisible"
    width="460px">
    <el-form :model="form" ref="form" size="small" :rules="rules" label-width="120px">
      <el-form-item label="客户名称">{{form.customerName}}</el-form-item>
      <el-form-item label="社会统一信用码">{{form.businessCode}}</el-form-item>
      <el-form-item label="开户行" prop="bankName">
          <el-input v-model="form.bankName"></el-input>
      </el-form-item>
      <el-form-item label="银行帐号" prop="bankAccount">
        <el-input v-model="form.bankAccount"></el-input>
      </el-form-item>
      <el-form-item label="公司地址" prop="addressInfo">
        <el-input v-model="form.addressInfo"></el-input>
      </el-form-item>
      <el-form-item label="电话" prop="customerPhone">
        <el-input v-model="form.customerPhone"></el-input>
      </el-form-item>
      <div style="padding:10px 0"><el-divider>收票信息</el-divider></div>
      <el-form-item label="收票人" prop="receiverName">
        <el-input v-model="form.receiverName"></el-input>
      </el-form-item>
      <el-form-item label="收票电话"  prop="receiverMobile">
        <el-input v-model="form.receiverMobile"></el-input>
      </el-form-item>
      <el-form-item label="收票地址"  prop="receiverAddress">
        <el-input v-model="form.receiverAddress"></el-input>
      </el-form-item>

    </el-form>

    <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="handleConfirm" :loading="btnLoading">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
import {getQiniuToken,saveTrackingInfo,getContactList,getCustomerSetting,orderGoodsList} from '@/api/partner'
import {developInvoiceInfoSet} from '@/api/company'
import {validatePhone} from '@/utils/validate';
import {formatDate} from '@/utils/date';
import store from '@/store'
import { mapGetters } from 'vuex'



const defaultForm = {
  "customerId" : '', //客户ID
  "bankName": "", //开户银行
  "bankAccount": "", //银行账号
  "addressInfo": "", //公司地址
  "customerPhone": "", //公司电话
  "receiverName": "", //收票人
  "receiverMobile": "", //收票人手机号
  "receiverAddress": "" ,//收票地址
  "customerName" : '',
  "businessCode" : '',
};
export default {
  name: "index",
  data(){
    return {
      dialogVisible:false,
      btnLoading:false,
      form:JSON.parse(JSON.stringify(defaultForm)),
      rules:{
        bankName:[{required: true, message: '此项必填', trigger: 'blur'},],
        bankAccount:[{required: true, message: '此项必填', trigger: 'blur'},],
        addressInfo:[{required: true, message: '此项必填', trigger: 'blur'},],
        customerPhone:[{required: true, message: '此项必填', trigger: 'blur'},],
        receiverName:[{required: true, message: '此项必填', trigger: 'blur'},],
        receiverMobile:[{required: true, message: '此项必填', trigger: 'blur'},],
        receiverAddress:[{required: true, message: '此项必填', trigger: 'blur'},],
      },
      checkList:[],
      radio:""

    }
  },
  computed: {
    ...mapGetters([
      'name',
      'mobile',
      'userId'
    ]),
  },
  components : {

  },
  created() {

  },
  filters: {

  },
  methods:{

    //显示
    showPop(item){
      this.dialogVisible = true;
      this.form = JSON.parse(JSON.stringify(item))
    },

    //关闭
    handleClose(){
      this.$refs.form.clearValidate();
      this.dialogVisible = false;
      this.btnLoading = false;
    },

    //提交
    handleConfirm(){
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.btnLoading = true;
          let data = JSON.parse(JSON.stringify(this.form));
          developInvoiceInfoSet(data).then((res)=>{
            this.btnLoading = false;
            this.handleClose();
            this.$emit('getInvoiceInfo')
          }).catch(()=>{
            this.btnLoading = false;
          })
        }
      })
    },
  },
}
</script>

<style  lang="scss">

</style>
